package com.heqiang.controller;


import com.heqiang.domain.Admin;
import com.heqiang.service.AdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
@RequestMapping("/admin")
@Slf4j
public class AdminController {

    @Autowired
    private AdminService service;

    /****************************************************** Query *****************************************************/

    /**
     * 查询-条件查询集合
     * zhang he qiang
     *
     * @Date 2020/7/23
     * @Return java.util.List<com.heqiang.domain.Admin>
     **/
    @RequestMapping("/findAll")
    public List<Admin> findAll(Admin admin, Model model) {
        log.info("==============查询管理员列表==============");
        return service.findAll(admin);
    }

    @RequestMapping("/findOne")
    public Admin findOne(Long id) {
        log.info("==============查询单个管理员==============");
        return service.selectByPrimaryKey(id);
    }

    @RequestMapping("/get")
    public String find() {
        log.info("==============远程调用测试1==============");
        return "远程调用测试1";
    }

    /********************************************************* MODIFY *****************************************************/
    @PostMapping("/add")
    public String find(@RequestParam(value = "account") String account,
                       @RequestParam(value = "password") String password,
                       @RequestParam(value = "phone") String phone,
                       @RequestParam(value = "roleId") Long roleId,
                       @RequestParam(value = "createTime") String createTime

    ) {
        log.info("==============新增管理员==============");
        System.out.println(account);
        System.out.println(password);
        System.out.println(phone);
        System.out.println(roleId);
        System.out.println(createTime);
        return "操作成功";
    }
}
